$(document).ready(function() {
	$("#begincodeBtn").click(search_begincode);
	$("#baiduyunBtn").click(search_baiduyun);
	$("#searchGo").click(search_begincode);
	$(window).keydown(function(e){
		var keyCode = e.which || e.keyCode;
		if(keyCode==13) {	//刷新按钮
			search_begincode();
			e.preventDefault();
			return;
		}
	});
});

function search_baiduyun() {
	var keyword=$("#search").val();
	if(keyword && keyword!=null){
		alert(keyword);
		$.ajax({
			type:"POST",
			url:"http://localhost:8080/result/allResults_baiduyun.htm?page=1",
			dataType:"json",
			data:{"keyword":keyword},
			success:function (data) {
				if(data.code==0){
					getResults(data,"getResultList_baiduyun");
					pagination(data.data,"allResults_baiduyun","getResultList_baiduyun","POST",keyword);
				}
			},
			error:function () {
				alert("error!!!!!!!!!!!!!");
			}
		});
	}else {
		window.location.href="";
	}
}
function search_begincode() {
	var keyword=$("#search").val();
	if(keyword && keyword!=null){
		alert("begincode"+keyword);
		$.ajax({
			type:"POST",
			url:"http://localhost:8080/result/allResults_begincode.htm?page=1",
			dataType:"json",
			data:{"keyword":keyword},
			success:function (data) {
				if(data.code==0){
					getResults(data,"getResultList_begincode");
					pagination(data,"allResults_begincode","getResultList_begincode",keyword);
				}
			},
			error:function () {
				alert("begincode_error!!!!!!!!!!!!!");
			}
		});
	}else {
		window.location.href="";
	}
}
